﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<ThietBiSo.LinQDB.Banner>" %>

<%@ Import Namespace="ThietBiSo.LinQDB" %>
<%@ Import Namespace="ThietBiSo.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Website - bảng điều khiển
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        function submitForm() {
            if (checkForm()) {
                document.forms[0].submit();
            }
        }


        function checkForm() {
            var flag = true;
            var F = document.forms[0];

           
            var ddlLoai = document.getElementById("ddlLoai").value;
            var HinhAnh = document.getElementById("HinhAnh").value;

            if (HinhAnh == null || HinhAnh == "") {
                alert("Chưa chọn hình ảnh");
                F.HinhAnh.focus();
                flag = false;

            }           
            else if (ddlLoai == null || ddlLoai == "") {
                alert("Chưa chọn loại banner");
                flag = false;
            }

            return flag;
        }

    </script>
    <%
   
        MQuangCao mqc = new MQuangCao();      
        var loaiqc = mqc.FindAll_LoaiQuangCao();
    %>
    <% using (Html.BeginForm("Create", "banner", FormMethod.Post, new { @enctype = "multipart/form-data" }))
       { %>
    <%: Html.ValidationSummary(true) %>
    <fieldset>
        <legend class="classFieldSet">Thêm mới banner</legend>
        <table width="100%">
            <tr>
                <td class="classCreate">
                    <input type="button" value="Thêm" class="btn" onclick="submitForm();" />
                </td>
                <td class="classBack">
                    <%: Html.ActionLink("Quay lại", "Index",null,new { @class = "classThem" })%>
                </td>
            </tr>          
            <tr>
                <td class="tableLabel">
                    Hình ảnh
                </td>
                <td class="tableField">
                    <%:Html.TextBox("HinhAnh")%>
                    <input type="button" value="Chọn ..." id="btnSelectImg" name="btnSelectImg" />
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $("#btnSelectImg").click(function () {
                                var finder = new CKFinder();
                                finder.selectActionFunction = function (fileUrl) {
                                    $('#HinhAnh').val(fileUrl);
                                };
                                finder.popup();
                            });
                        });
                    </script>
                    <%--  <input class="field" type="file" name="fileUpload" id="fileUpload" style="width: 100%;" />--%>
                </td>
            </tr>
            
            <tr>
                <td class="tableLabel">
                    Loại banner
                </td>
                <td class="tableField">
                    <%: Html.DropDownList("ddlLoai", new SelectList(loaiqc, "MaLoaiQuangCao", "TenLoaiQuangCao"), "Chọn loại banner", new { @style = "width:400px" })%>
                </td>
                <td style="color:Red">
                Image: 1000 x auto <br />
                Flash: 1000 x 125
                </td>
            </tr>
        </table>
    </fieldset>
    <% } %>
</asp:Content>
